-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reverseproxy: Set the headers in the replacer before handle_response
#4165
Conversation
Turns out this was an oversight, we assumed we could use `{http.response.header.*}` but that doesn't work because those are grabbed from the response writer, and we haven't copied any headers into the response writer yet. So the fix is to set all the response headers into the replacer at a new namespace before running the handlers. This adds the `{http.reverse_proxy.header.*}` replacer. See https://caddy.community/t/empty-http-response-header-x-accel-redirect/12447
handle_response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, interesting situation... I guess this'll work, assuming we never need to differentiate request headers and response headers in the future.
I think we'd go with |
I have another related issue: If the upstream server returns a
Update: Same applies to the |
That's normal. No headers are copied by default in |
I see that |
Where do you see that @corny? The code doesn't copy any headers. caddy/modules/caddyhttp/reverseproxy/reverseproxy.go Lines 613 to 652 in b82db99
What does your Caddyfile look like? How did you build Caddy? |
Turns out this was an oversight, we assumed we could use
{http.response.header.*}
but that doesn't work because those are grabbed from the response writer, and we haven't copied any headers into the response writer yet.So the fix is to set all the response headers into the replacer at a new namespace before running the handlers.
This adds the
{http.reverse_proxy.header.*}
replacer.See https://caddy.community/t/empty-http-response-header-x-accel-redirect/12447